package org.huangrui.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author hr
 * @Create 2025-11-11 13:04
 **/
@Slf4j
@RestController
public class OllamaController {
    @Autowired
    private OllamaChatModel chatModel;

    @GetMapping("/ollama")
    public String ollama(@RequestParam(value = "message",defaultValue = "hello")
                         String message) {
        String result = chatModel.call(message);
        log.info("result: {}", result);
        return result;
    }
}
